package org.asg.dis.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

public class ResponseUtil<T> {

    public static <T> ResponseEntity<T> ok(T data) {
        return ResponseEntity
                .status(HttpStatus.OK)
                .header("message", "成功")
                .body(data);
    }

    public static <T> ResponseEntity<T> ok(String message) {
        return ResponseEntity
                .status(HttpStatus.OK)
                .header("message", message)
                .body(null);
    }

    public static <T> ResponseEntity<T> ok() {
        return ResponseEntity
                .status(HttpStatus.OK)
                .header("message", "成功")
                .body(null);
    }

    public static <T> ResponseEntity<T> error(HttpStatus status, String message) {
        return ResponseEntity
                .status(status)
                .header("message", message)
                .body(null);
    }
}
